/*
 * TextOptions_Beans.java
 *
 * Created on December 10, 2008, 3:02 PM
 */

package gui.beans;

/**
 * 
 * @author Jason
 */
public abstract class TextOptions_Beans extends javax.swing.JPanel {

	/** Creates new form TextOptions_Beans */
	public TextOptions_Beans() {
		initComponents();
	}

	protected abstract void updateTitle(String text);

	protected abstract void updateText(String text);

	/**
	 * This method is called from within the constructor to initialize the form.
	 * WARNING: Do NOT modify this code. The content of this method is always
	 * regenerated by the Form Editor.
	 */
	// <editor-fold defaultstate="collapsed" desc="Generated Code">
	private void initComponents() {

		jLabel1 = new javax.swing.JLabel();
		jScrollPane1 = new javax.swing.JScrollPane();
		inputTextArea = new javax.swing.JTextArea();
		titleField = new javax.swing.JTextField();

		jLabel1.setText("Title: ");

		inputTextArea.setColumns(20);
		inputTextArea.setRows(5);
		inputTextArea.addFocusListener(new java.awt.event.FocusAdapter() {
			@Override
			public void focusLost(java.awt.event.FocusEvent evt) {
				inputTextAreaFocusLost(evt);
			}
		});
		jScrollPane1.setViewportView(inputTextArea);

		titleField.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				titleFieldActionPerformed(evt);
			}
		});
		titleField.addFocusListener(new java.awt.event.FocusAdapter() {
			@Override
			public void focusLost(java.awt.event.FocusEvent evt) {
				titleFieldFocusLost(evt);
			}
		});

		javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
		this.setLayout(layout);
		layout.setHorizontalGroup(layout.createParallelGroup(
				javax.swing.GroupLayout.Alignment.LEADING).addGroup(
				layout.createSequentialGroup().addContainerGap().addComponent(
						jLabel1).addPreferredGap(
						javax.swing.LayoutStyle.ComponentPlacement.RELATED)
						.addComponent(titleField,
								javax.swing.GroupLayout.DEFAULT_SIZE, 135,
								Short.MAX_VALUE).addContainerGap())
				.addComponent(jScrollPane1,
						javax.swing.GroupLayout.Alignment.TRAILING,
						javax.swing.GroupLayout.DEFAULT_SIZE, 186,
						Short.MAX_VALUE));
		layout
				.setVerticalGroup(layout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								layout
										.createSequentialGroup()
										.addContainerGap()
										.addGroup(
												layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(jLabel1)
														.addComponent(
																titleField,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.PREFERRED_SIZE))
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(
												jScrollPane1,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												263, Short.MAX_VALUE)));
	}// </editor-fold>

	private void titleFieldFocusLost(java.awt.event.FocusEvent evt) {
		String text = titleField.getText();
		if (text.length() > 0) {
			updateTitle(text);
		}
	}

	private void inputTextAreaFocusLost(java.awt.event.FocusEvent evt) {
		String inputText = inputTextArea.getText();
		updateText(inputText);
	}

	private void titleFieldActionPerformed(java.awt.event.ActionEvent evt) {
		String text = titleField.getText();
		if (text.length() > 0) {
			updateTitle(text);
		}
	}

	// Variables declaration - do not modify
	protected javax.swing.JTextArea inputTextArea;
	protected javax.swing.JLabel jLabel1;
	protected javax.swing.JScrollPane jScrollPane1;
	protected javax.swing.JTextField titleField;
	// End of variables declaration

}
